<?php
namespace app\common\model;

use app\common\traits\Text;
use think\Db;
use think\Model;
use think\facade\Session;

class Renwus extends Model
{
    use Text;


    /**
     * 用户状态修改器
     * @param $value
     * @param $data
     * @return mixed
     */
    public function getStatusTextAttr($value, $data)
    {
        $status = [1=>'<span class="label label-success">正常</span>',2=>'<span class="label label-danger">禁用</span>'];
        return $status[$data['status']];
    }
    public function getRwlxTextAttr($value, $data)
    {
        $info = Db::name('renwuleixing')->where(['id'=>$data['rwlx_id']])->field('name')->find();
        return $info['name'];
    }
    public function getDeparTextAttr($value, $data)
    {
        $status = Leibie::bumen();
        return $status[$data['depar_id']];
    }
    public function getYgroupTextAttr($value, $data)
    {
        $info = Db::name('ygroup')->where(['id'=>$data['ygroup_id']])->field('group_name')->find();
        return $info['group_name'];
    }

    public function getRenwuleixing(){
        $info = Db::name('renwuleixing')->where(['status'=>1])->field('id,name')->select();
        return $info;
    }

    public function getYgroup(){
        $info = Db::name('ygroup')->where(['status'=>1,'depar_id'=>3])->field('id,group_name')->select();
        return $info;
    }

}